#include "claunchwindow.h"

#include <buola/widgets/cdialoglayoutmanager.h>
#include <buola/os/cprocess.h>

namespace buola { namespace bdesktop {

CLaunchWindow::CLaunchWindow()
{
    
}

void CLaunchWindow::OnCreate()
{
    Resize(CSize(600,116));
    SetTitle(WI18N("Launch application"));

    gui::CDialogLayoutManager *lLayout=gui::CDialogLayoutManager::Get(this);

    mLabelBox.Create(this);
    mLabelBox.SetCaption(L"enter a command or URL to launch");
    mEditBox.Create(this);
    mTerminalBox.Create(this);
    
    lLayout->At(&mLabelBox,20,24,WLAY_RIGHT-20,48);
    lLayout->At(&mEditBox,20,48,WLAY_RIGHT-20,72);
    lLayout->At(&mTerminalBox,50*WLAY_PERC,72,WLAY_RIGHT-20,96);

    mEditBox.eEnter.Connect(&CLaunchWindow::OnEnter,this);
    
    ShowAllChildren();
}

void CLaunchWindow::OnEnter()
{
    CProcess lProcess(encode(mEditBox.GetCaption()),CProcess::DETACH|CProcess::SHELL);
    lProcess.Launch();
    Destroy();
}

/*namespace bdesktop*/ } /*namespace buola*/ }
